﻿Imports System.Windows.Forms
Imports System.Drawing

Class MainWindow
    Public NotifyIcon1 As New NotifyIcon
    Private Async Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        If _Name.Text.Length > 0 And _Password.Password.Length > 0 Then
            ProgressBar1.IsIndeterminate = True
            Dim a = Await SpacesPost("http://spaces.ru/registration/?r=reg/loginform", "name=" & _Name.Text & "&password=" & _Password.Password)
            My.Settings.Bookmark = Split(Split(a, "href=""")(1), """>here<")(0)
            My.Settings.Save()
            a = Await SpacesPost(My.Settings.Bookmark)
        Else
            MsgBox("Заполните все поля!")
        End If
    End Sub

    Private Async Sub Window_Loaded_1(sender As Object, e As RoutedEventArgs)
        If Not My.Settings.Bookmark Like "*/tm/*" Then
            Me.Show()
        Else
            Me.Hide()
            Dim a = Await SpacesPost(My.Settings.Bookmark)
            My.Settings.Name = Split(Split(a, "<title>Старт/")(1), "</title>")(0)
            My.Settings.Save()
        End If
        With NotifyIcon1
            .Visible = True
            .Icon = My.Resources.logo_big
            .Text = "Вы онлайн"
            .BalloonTipTitle = "Привет"
            .BalloonTipText = "Добро пожаловать в SpacesLive:)"
            .ShowBalloonTip(3)
        End With
        Dim b As New SpacesLive
        b.Show()
    End Sub
End Class
